using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using Moq;
using OpenWaves.ActivityFeed.Web;

namespace OpenWaves.ActivityFeed.UnitTests.Web
{
    public class IdentityProviderMock
    {
        public static IUserIdentityProvider With(string userId)
        {
            var identityProviderMock = new Mock<IUserIdentityProvider>();
            identityProviderMock.Setup(i => i.Identity).Returns(new GenericIdentity(userId));
            return identityProviderMock.Object;
        }

        public static IUserIdentityProvider WithAnonymousUser()
        {
            var identityProviderMock = new Mock<IUserIdentityProvider>();
            identityProviderMock.Setup(i => i.Identity).Returns(new Mock<IIdentity>().Object);
            return identityProviderMock.Object;
        }

    }

    public class UserGroupsProviderMock
    {
        public static IUserGroupMembershipProvider With(params UserGroup[] groups)
        {
            var groupMembershipProvider = new Mock<IUserGroupMembershipProvider>();
            groupMembershipProvider.Setup(i => i.UserGroups).Returns(groups);
            return groupMembershipProvider.Object;
        }

        public static IUserGroupMembershipProvider WithNoGroups()
        {
            var groupMembershipProvider = new Mock<IUserGroupMembershipProvider>();
            groupMembershipProvider.Setup(i => i.UserGroups).Returns(Enumerable.Empty<UserGroup>());
            return groupMembershipProvider.Object;
        }
    }
}